iter=5
pushd col$1
while true; do
    rm -rf collector.log collector.err
    echo "Running $iter tests..."
    date
    java traverser/FrequencyCollector $iter > collector.log 2> collector.err
    success=$?
    echo "Completed $iter tests with result $success, sending mail"

    touch temp-message.txt
    echo "Finished running $iter tests with result $success" > temp-message.txt
    echo.
    echo "Contents of error file:" >> temp-message.txt
    echo.
    cat collector.err >> temp-message.txt
    /bin/mailx -s "Wikicrawler test completed" $USER < temp-message.txt
    rm -f temp-message.txt
done

popd

echo "Encountered an error of some sort! see collector.err"
